package 强化训练;

import java.util.Scanner;

public class day39字符串计数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){

            //1，处理输入
            StringBuilder s1 = new StringBuilder(sc.next());
            StringBuilder s2 = new StringBuilder(sc.next());
            int len1 = sc.nextInt();
            int len2 = sc.nextInt();

            //拼接字符串，因为len2 > len1，所以拼接成len2的长度
            for (int i = s1.length(); i < len2; i++) {
                s1.append('a');
            }
            for (int i = s2.length(); i < len2; i++) {
                s2.append((char)('z' + 1));
            }

            //处理各位之间的关系，将处理结果保存在数组中
            int[] arr = new int[len2];
            for (int i = 0; i < len2; i++) {
                arr[i] = s2.charAt(i) - s1.charAt(i);
            }

            //处理结果
            long res = 0;
            for (int i = len1; i <= len2; i++) {//长度范围
                for (int j = 0; j < i; j++) {//arr的下标，及字符串的第几位
                    //如果长度为1，就从arr[0]开始，arr[0] 是 26的0次方
                    res += arr[j] * Math.pow(26,i - j - 1);//所以这里是i-j-1
                }
            }

            System.out.println((res - 1) % 1000007);
        }
    }
}
